import { CustomForm } from "@/components/ProForm/interface";
export const useForm = () => {
  const addForm = reactive<CustomForm>({
    // 是否可编辑
    editable: true,
    save: () => null,
    form: {
      newPassword: "",
      oldPassword: "",
      username: ""
    },
    options: [
      {
        type: "title",
        label: "基础信息",
        hide: false
      },
      {
        type: "select",
        label: "主题色",
        prop: "theme",
        hide: false,
        children: [
          {
            text: "高级黑",
            value: "default-theme"
          },
          {
            text: "科技蓝",
            value: "blue-theme"
          },
          {
            text: "夏日橙",
            value: "orange-primary"
          },
          {
            text: "枫叶红",
            value: "jade-primary"
          }
        ],
        rules: [
          {
            required: true,
            errorMessage: "主题色不能为空"
          }
        ],
        changeMethod: (form: any) => {
          useThemeStore().setTheme(form.theme);
          uni.reLaunch({
            url: "/pages/home/index"
          });
        },
        attrs: {
          disabled: false,
          clear: false
        }
      }
    ]
  });

  const submitForm = async () => {
    uni.reLaunch({
      url: "/pages/login/index"
    });
  };

  return {
    addForm,
    submitForm
  };
};
